package kata.chop;

public class IterativeBinaryChop extends BinaryChop {

	@Override
	protected int chop() {
		while (startPosition <= endPosition) {
			computeMiddle();
			if (found())
				return middlePosition;
			if (searchTheLeftHalf())
				endPosition = middlePosition - 1;
			if (searchTheRightHalf())
				startPosition = middlePosition + 1;
		}
		return NOT_FOUND;
	}

}
